<template>
  <div class="sale-sell">
    <van-nav-bar @click-left="$router.go(-1)" left-arrow title="促销商品"/>
    <tab-item :data="saleSell" @showGood="showGood"></tab-item>
  </div>
</template>

<script>
import tabItem from "../../components/tabItem";

export default {
  name: "saleSell",
  data() {
    return {
      saleSell: []
    };
  },
  created() {
    this.getSaleGoods();
  },
  methods: {
    // 跳转商品详情
    showGood(id) {
      this.$router.push({path: "/Goods/detail", query: {id}});
    },

    // 获取获取更多数据的
    getSaleGoods() {
      this.$axios.post(this.$api.getSaleGood, {all: "1"}).then(res => {
        if (res.status === 200 && res.data.code === 200) {
          this.saleSell = res.data.data;
        } else {
          this.$toast.fail("促销商品加载失败");
        }
      }).catch(err => {
        console.log(err);
      });
    },
  },
  components: {tabItem}
};
</script>

<style lang="less" scoped>
.sale-sell {
  background-color: #eee;
  min-height: 100/16rem;
}
</style>
